package com.yumei.trader.gym.act;

import android.content.Context;

public abstract  class BaseAct {

    //现金帐户
    private double cashValue;
    //成本资金
    private double costValue;

    protected Context context;

    public BaseAct(Context context){
        this.context = context;
    }

    public double getCashValue(){
        return cashValue;
    }

    public float getTotalRise(){
        return (float)((cashValue - costValue)/costValue);
    }

    public float getTotalValue(){
        return (float) (cashValue - costValue);
    }

    public void reset(){
        cashValue = loadCashAccount();
        costValue = cashValue;
    }

    /**
     * 资金转出
     * @param value
     */
    protected boolean turnOutValue(double value){

        if(cashValue - value >0){
            cashValue -= value;
            return true;
        }
        return false;
    }


    /**
     * 资金转入
     * @param value
     */
    protected  void  turnInValue(double value){
        cashValue += value;
        //saveCashAccount();
    }

    //加载资金
    protected abstract double loadCashAccount();

    //存储资金
    protected abstract void saveCashAccount();

}
